﻿using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CPPEI.Coolzon.Core
{
    public class DbContext : IDisposable
    {
        public DbConnection DbConnection { get; private set; }

        public DbContext()
        {
            // 在这里初始化连接
            string strConn = System.Configuration.ConfigurationManager.ConnectionStrings["CoolzonManagementCenter"].ConnectionString;
            DbConnection = new SqlConnection(strConn);
            DbConnection.Open();
        }

        public void Dispose()
        {
            // 在这里释放连接资源
            if (DbConnection != null)
            {
                DbConnection.Close();
                DbConnection.Dispose();
            }
        }
    }
}
